<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">
    var rowId = 0;
    
    $('.ui-reset , #refresh_dependentGrid').click(function(){
        $("#dependentGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#dependentGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#dependentGrid").trigger("reloadGrid");
    });

    $.subscribe('searchDependentGrid', function(event,data) {
        $("#dependentGrid").jqGrid('searchGrid', {drag:true,closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:"Search Dependents"} );
    });
    
    $.subscribe('dependentGridComplete',function(event,data){
        $( "#dependentGrid_search" ).button( "option", "disabled", false );
    });
    
</script>
<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="dependentGrid_search" onClickTopics="searchDependentGrid" value="Search Dependents"/>
</div>
<s:url id="remoteurl" action="grid-dependents"/>
<s:url id="editurl" action="edit-dependents"/>
<sjg:grid
    id="dependentGrid"
    caption="Borrower's Dependents"
    dataType="json"
    href="%{remoteurl}"
    cellEdit="true"
    cellurl="%{editurl}"
    gridModel="gridModel"
    pager="true"
    pagerButtons="true"
    pagerInput="true"
    rowList="15,30,50"
    rowNum="15"
    loadingText="Requesting Data..."
    width="970"
    shrinkToFit="true"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="true"
    navigatorView="true"
    onGridCompleteTopics="dependentGridComplete"
    >

    <sjg:gridColumn name="dependentid"
                    key="true"
                    index="dependentid"
                    title="dependentid. (Not Editable)"
                    sortable="false"
                    hidden="true"
                    align="center"
                    />

    <sjg:gridColumn name="name"
                    index="name"
                    title="Name"
                    sortable="true"
                    editable="true"
                    edittype="text"
                    editrules="{required:true}"
                    editoptions="{maxlength:'45'}"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="age"
                    index="age"
                    title="Age"
                    editable="true"
                    edittype="text"
                    editrules="{required:true,number:true}"
                    editoptions="{maxlength:'2'}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="relationship"
                    index="relationship"
                    title="Relationship"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="borrowercode"
                    index="borrowercode"
                    title="Borrower"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="loanappdocumentno"
                    index="loanappdocumentno"
                    title="Loan Application Document"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
</sjg:grid>
